<?php
namespace Admin\Controller;
use Think\Controller;
class MessageController extends BackController {
	/**
	 * 初始化
	 */
	public function __construct() {
		parent::__construct();
	}

	/**
	 * 列表
	 */
    public function index() {
		$data = D('message')->mselect(); 
		$this->assign('list',$data['list']);
		$this->assign('page',$data['page']);
		$this->display();
    }

	/**
	 * 添加、修改
	 */
	public function edit() {
		$id = I('get.mid','','intval');
		if(!empty($id)) {
			$info = D('message')->find($id);
			$this->assign('info',$info);
			if(!empty($info)) {
				$userinfo = D('address')->find($info['muid']);
				$this->assign('userinfo',$userinfo);
			}
		} else {
			die('need id');
		}
		$this->display();
	}

	/**
	 * 删除
	 */
	public function del() {
		$id = I('get.id','','intval');
		if(!empty($id)) {
			$msg = D('message')->delete($id);
			if(empty($msg)) {
				$this->error('操作失败！',U('Message/index'));
			} else {
				$this->success('操作成功！',U('Message/index'));
			}
		}
	}

}
